package com.hsogoo.avatar.executor;

import java.util.concurrent.ThreadFactory;

import com.hsogoo.avatar.NamedThreadFactory;

/**
 * Created by za-huangsaigang on 2018/10/24.
 */
public abstract class AbstractExecutorFactory implements ExecutorFactory {

    protected ThreadFactory threadFactory(String name) {
        return new NamedThreadFactory(name);
    }

    protected int coreWorkers(Target target) {
        switch (target) {
            case CONSUMER:
                return 10;
            case PROVIDER:
                return 20;
            default:
                throw new IllegalArgumentException(String.valueOf(target));
        }
    }

    protected int maxWorkers(Target target) {
        switch (target) {
            case CONSUMER:
                return 20;
            case PROVIDER:
                return 50;
            default:
                throw new IllegalArgumentException(String.valueOf(target));
        }
    }

    protected int queueCapacity(Target target) {
        switch (target) {
            case CONSUMER:
                return 128;
            case PROVIDER:
                return 256;
            default:
                throw new IllegalArgumentException(String.valueOf(target));
        }
    }
}
